# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: Morteza NourelahiAlamdari <m@0t1.me>
# Contributor: Caltlgin Stsodaat <contact@fossdaily.xyz>

pkgname=python-oyaml
_pkgname="${pkgname#python-}"
pkgver=1.0
pkgrel=5
pkgdesc="A drop-in replacement for PyYAML which preserves dict ordering"
arch=('any')
url="https://github.com/wimglenn/oyaml"
license=('MIT')
depends=('python' 'python-yaml')
makedepends=('git' 'python-setuptools')
checkdepends=('python-pytest')
_commit='45bef7ee676e30a68a122fbac9801727e0064aab' # v1.0
source=("$pkgname::git+$url.git#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd "$pkgname"

  git describe --tags | sed 's/^v//'
}

prepare() {
  cd "$pkgname"

  # backport usage of yaml's safe_load function
  git cherry-pick --no-commit 7381373cec378a464e1cf4ca8b03c6cb8493469b
}

build() {
  cd "$pkgname"

  python setup.py build
}

check() {
  cd "$pkgname"

  pytest 
}

package() {
  cd "$pkgname"

  python setup.py install --root="$pkgdir" --optimize=1

  # documentation
  install -vDm644 -t "$pkgdir/usr/share/doc/$pkgname" README.rst

  # license
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
}
